package com.inputabc.ct.v1.ui.inputbox.component;

import com.inputabc.ct.v1.context.ContextParams;
import com.inputabc.ct.v1.ui.inputbox.InputBoxBuilder;

import javax.swing.*;
import java.awt.*;

public class InputBoxCloseButtonFrame extends JFrame {
    private InputBoxFrame inputBoxFrame;
    private InputBoxCloseButtonPanel inputBoxCloseButtonPanel;

    {
        inputBoxFrame = ((InputBoxBuilder) ContextParams.contextParam.get("inputBoxBuilder")).getInputBoxFrame();
        inputBoxCloseButtonPanel = new InputBoxCloseButtonPanel();
    }

    public InputBoxCloseButtonFrame() {
        // 设置内容面板
        setContentPane(inputBoxCloseButtonPanel);
        
        // 设置窗口属性
        setUndecorated(true);
        setAlwaysOnTop(true);
        setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        
        // 设置背景透明
        setBackground(new Color(0, 0, 0, 0));
    }
    
    /**
     * 重写窗口绘制方法
     */
    @Override
    public void paint(Graphics g) {
        // 使用抗锯齿渲染
        Graphics2D g2d = (Graphics2D) g.create();
        g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
        g2d.dispose();
        
        super.paint(g);
    }

    public InputBoxCloseButtonPanel getInputBoxCloseButtonPanel() {
        return inputBoxCloseButtonPanel;
    }

    public void setInputBoxCloseButtonPanel(InputBoxCloseButtonPanel inputBoxCloseButtonPanel) {
        this.inputBoxCloseButtonPanel = inputBoxCloseButtonPanel;
    }
}
